package com.e3.template.tgf;

import java.util.List;

import com.e3.web.core.model.SuperModel;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;

public abstract class MyGFUI<D extends SuperModel> extends SuperGFUI<D>{
	
	@Override
	protected void onRender(Element parent, int index) {
		super.onRender(parent, index);
		this.setLayout(new FitLayout());

		BorderLayoutData bld = new BorderLayoutData(LayoutRegion.NORTH);
		bld.setSplit(true);
		bld.setMargins(new Margins(0,2,0,0));
		getRightContentPanel().add(getGridPanel(),bld);
		
		bld = new BorderLayoutData(LayoutRegion.CENTER);
		getRightContentPanel().add(getFormPanel(),bld);
		getFormPanel().setFormReadonly(true);
		
		
		initToolBar();
		getRightContentPanel().setTopComponent(getToolbar());
		getRightContentPanel().setHeaderVisible(false);

		this.add(getRightContentPanel());
	}

	protected List<D> getCurrentSelectedModels(){
		return getGridPanel().getSelectedModels();
	}
	
	public void onEditSuccess(D model) {
		getGridPanel().refreshGridModel(model);
	}
	
	protected void onDeleteSuccess(List<D> models){
		getGridPanel().removeValues(models);
	}
	
}
